home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
windows
/
objdata.zip
/
TESTPROG.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-09
|
4KB
|
185 lines
#include <iostream.h>
#include <string.h>
#include <stdio.h>
#include <windows.h>
#include "f_type.h"
#include "bdkernel.h"
void Message(char *c, int i) {
char *cc;
cc = new char[strlen(c) + 20];
sprintf(cc,"%s: %d \n",c,i);
MessageBox(NULL, cc, "Debug info.", MB_ICONINFORMATION|MB_TASKMODAL);
delete [] cc;
return;
}
int main() {
// some local variables
int status; // used to hold return values
const int StubID = 0; // Must be zero
int FuncID; // Select the function number
char c[100]; // some strings
char d[100];
char e[100];
unsigned long Data[10]; // array used to pass all data
struct str { int i; int j; float k; } mystr; // my user defined struct
struct str2{ int i; int j; float k; } mystr2;
// fill in some data
mystr.i=12;
mystr.j=13;
mystr.k=1.234;
/* PART 1
This section is ALWAYS required.
It initialises the object data system
*/
// startup
FuncID = 0;
status = (int)callout(StubID, FuncID, (unsigned long)Data);
Message("Initialisation", status);
/* PART 2
This section creates some data objects and fills in
some data.
*/
// create an object
strcpy(c,"object3");
FuncID = 4;
Data[0] = (unsigned long)c;
status = callout(StubID, FuncID, (unsigned long)Data);
Message("Creating object3", status);
// create a second object
strcpy(c,"object4");
FuncID = 4;
Data[0] = (unsigned long)c;
status = callout(StubID, FuncID, (unsigned long)Data);
// store some data
strcpy(c,"object3.a");
Data[0] = (unsigned long)c;
Data[1] = (unsigned long)&mystr;
Data[2] = sizeof(mystr);
Data[3] = 0;
Data[4] = 0;
FuncID = 12;
status = callout(StubID, FuncID, (unsigned long)Data);
Message("storing data in object3.a", status);
// re-read the user type
strcpy(c,"object3.a");
Data[0] = (unsigned long)c;
Data[1] = (unsigned long)&mystr2;
status = callout(0,11,(unsigned long)Data);
Message("Reading data from object3.a", status);
int a = 33;
strcpy(c,"object3.b");
Data[0] = (unsigned long)c;
Data[1] = (unsigned long)&a;
Data[2] = 1;
Data[3] = 1;
Data[4] = 0;
FuncID = 8;
status = callout(StubID, FuncID, (unsigned long)Data);
a = 44;
strcpy(c,"object4.x");
Data[0] = (unsigned long)c;
Data[1] = (unsigned long)&a;
Data[2] = 1;
Data[3] = 1;
Data[4] = 0;
FuncID = 8;
status = callout(StubID, FuncID, (unsigned long)Data);
a = 55;
strcpy(c,"object4.y");
Data[0] = (unsigned long)c;
Data[1] = (unsigned long)&a;
Data[2] = 1;
Data[3] = 1;
Data[4] = 0;
status = callout(StubID, FuncID, (unsigned long)Data);
// tag all objects
FuncID = 22;
status = callout(StubID, FuncID,
(unsigned long)Data);
// save
strcpy(c,"bbb.txt");
Data[0] = (unsigned long)c;
Data[1] = 0;
Data[2] = 0;
FuncID = 18;
Message("Ready to save the data",0);
status = callout(StubID, FuncID, (unsigned long)Data);
Message("Saving data", status);
/* PART 3
Reads an already created data file
*/
// read a file
strcpy(c,"bbb.txt");
Data[0] = (unsigned long)c;
Data[1] = 0;
FuncID = 19;
status = callout(StubID, FuncID, (unsigned long)Data);
Message("Reading file", status);
// count registered objects
FuncID = 7;
status = callout(StubID, FuncID, (unsigned long)Data);
status = Data[0];
Message("Registered objects", status);
/* PART 4
Reads a data value from memory
*/
// read some date
float b;
strcpy(c,"fred.b");
Data[0] = (unsigned long)c;
Data[1] = (unsigned long)&b;
Data[2] = 6;
Data[3] = 1;
Data[4] = 0;
FuncID = 10;
status = callout(StubID, FuncID, (unsigned long)Data);
// read some date
int s;
strcpy(c,"fred.c");
Data[0] = (unsigned long)c;
Data[1] = (unsigned long)&s;
Data[2] = 2;
Data[3] = 1;
Data[4] = 0;
FuncID = 10;
status = callout(StubID, FuncID, (unsigned long)Data);
/* PART 5
This function clears up the data system.
It must always be present
*/
// clear up
FuncID = 1;
status = callout(StubID, FuncID,(unsigned long)Data);
Message("Shutdown", status);
return 0;
}